package com.pdsu.graduation_design.listener;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Toast;

import com.pdsu.graduation_design.domain.Commodity;
import com.pdsu.graduation_design.views.MainListViewItemDetailActivity;

import java.util.List;

public class MainActivityListViewListener implements AdapterView.OnItemClickListener {



    //参数
    private Context context;
    private List<Commodity> commodities;

    public MainActivityListViewListener(Context context, List<Commodity> commodities) {
        this.context = context;
        this.commodities = commodities;
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

        /**
         * 根据postion 和commodites获得所点击商品的信息
         *
         */
        Intent intent=new Intent(context,MainListViewItemDetailActivity.class);
        intent.putExtra("cid",commodities.get(position).getCid());
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
    }
}
